$( document ).on( "pageshow", "#myInfo_page", function( event ) {
	access_token=getQueryString("access_token");
	
	load_myInfoPageInfo();
});

$( document ).on( "pagecreate", "#myInfo_page", function( event ) {
	
});

function load_myInfoPageInfo(){
	$.ajax({
	  	url: rootPath+"/user/personInfo.do",
	  	type: "POST",
	  	dataType: "text",
		data: "access_token="+access_token,
	  	success: function( response ) {
	  		var data=$.parseJSON(response);
	  		
			if(data.state=="200"){
		  		var user=data.data;
		  		var userTelephone=user.telephone==undefined||user.telephone==null? "":user.telephone;
		  		var userWorkEmail=user.work_email==undefined||user.work_email==null? "":user.work_email;
		  		var sendFlowerNum=user.sendFlowerNum==undefined||user.sendFlowerNum==null? "0":user.sendFlowerNum;
		  		var userDeptName=user.deptName==undefined||user.deptName==null? "":user.deptName;
		  		$("#userName_myInfo").text(user.empName);
		  		$("#userGrade_myInfo").text(user.integralGrade);
		  		$("#userIntegralNum_myInfo").text(user.integralNum);
		  		$("#userFlowerNum_myInfo").text(parseInt(user.redFlowerNum+user.fdFlowerNum));
		  		$("#userDeptName_myInfo").text(userDeptName);
		  		$("#userTelephone_myInfo").val(userTelephone);
		  		$("#userWorkEmail_myInfo").text(userWorkEmail);
		  		
		  		$("#sendFlowerNum_myInfo").text(parseInt(sendFlowerNum));
		  		$("#addFlowerNum_myInfo").text(parseInt(user.redFlowerNum));
		  		
		  		var canSendNumOfToday=user.canSendNumOfToday;
		  		if(canSendNumOfToday=="-1"){//无限制赠送
		  			var canPic='<img src="'+rootPath+flower_+'"/>';
		  			$("#canSengNumShow_myInfo").html(canPic+"现在送花无限制，此时不送更待何时！");
		  		}else{
			  		var canPic="";
			  		var flowNum = 0 ;
			  		if(canSendNumOfToday>3){
			  			flowNum = 2 ;
			  		}else{
			  			flowNum = canSendNumOfToday ;
			  		}
//			  		for(var i=0;i<flowNum;i++){
			  			canPic='<img src="'+rootPath+flower_+'"/>';
//			  		}
			  		$("#canSengNumShow_myInfo").html(canPic+"还有[ "+canSendNumOfToday+" ]次赠送机会哦！");
		  		}
		  		if(!canSendNumOfToday&&canSendNumOfToday==0){
		  			$("#btn_go_send_myInfo").hide();
		  		}else{
		  			$("#btn_go_send_myInfo").show();
		  			//去赠送链接
		  			$( "#btn_go_send_myInfo" ).on("click",function (){
		  				goTo(rootPath+"/jsp/weixin/searchEmp.jsp?access_token="+access_token);
		  			});
		  		}
		  		
		  		var userHeadPic=user.headImageUrl==undefined||user.headImageUrl==null? rootPath+defaultHeadPic :user.headImageUrl;
		  		
		  		$("#userHead_myInfo").attr("src",userHeadPic).show();
		  		$("#userIntegralPic_myInfo").attr("src",rootPath+user.inteGraPic);
		  		
		  		var flowerUrl="";
		  		if(user.redflowerState=="死掉"){
		  			flowerUrl=flower_die;
		  		}else if(user.redflowerState=="枯萎"){
		  			flowerUrl=flower_droop;
		  		}else if(user.redflowerState=="盛开"){
		  			flowerUrl=flower_bloom;
		  		}
		  		$("#userFlowerStatePic_myInfo").attr("src",rootPath+flowerUrl);
		  		
		  		//我的红花链接
		  		$( "#flowerDetail_myInfo" ).on("click",function (){
		  			goTo(rootPath+"/jsp/weixin/myFlower.jsp?access_token="+access_token);
		  		});
		  		//我的积分
		  		$( "#userIntegralPic_myInfo" ).on("click",function (){
		  			goTo(rootPath+"/jsp/weixin/myIntegral.jsp?access_token="+access_token);
		  		});
			}else{
				alert_wx('fail',data.msg);
			}
	  	}
	});
}